package cn.edu.ustc.multicore.exercise.ch5;

public class CriticalSection {
	private static CriticalSection instance = new CriticalSection();
	private long wcount = 0l;
	private long rcount = 0l;
	private String text = null;
	
	private CriticalSection(){
		wcount = 0l;
	}
	public static CriticalSection getInstance(){
		return instance;
	}
	public String read(){
		rcount++;
		return text;
	}
	
	public long getWriteTimes() {
		return wcount;
	}
	
	public long getReadTimes(){
		return rcount;
	}
	
	public void write(String text ){
		this.text = text;
		wcount++;
	}
	public void reset(){
		wcount = 0;
		rcount = 0;
	}
}
